<template>
  <div class="goods-item" @click="itemClick">
    <img :src="goodsItem.show.img" alt="" @load="imageLoad">
    <div class="goods-info">
      <p>{{goodsItem.title}}</p>
      <span class="price">{{goodsItem.price}}</span>
      <span class="collect">❤{{goodsItem.cfav}}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "GoodsListItem",
  props:{
    goodsItem:{
      type:Object,
      default(){
        return {}
      }
    }
  },
  methods:{
    imageLoad(){
      // console.log('imageLoad')
      this.$bus.$emit('itemImageLoad')
    },
    itemClick(){
      // console.log('跳转到详情页')
      this.$router.push('/detail/' + this.goodsItem.iid )
      //路径后面加上id
    }
  }
}
</script>

<style scoped>
  .goods-item{
    padding-bottom: 20px;
    position: relative;
    width: 48%;
  }
  .goods-item img{
    width: 100%;
    border-radius: 5px;
  }
  goods-info{
    position: absolute;

    bottom: 5px;
    left: 0;
    right: 0;
    overflow: hidden;
    text-align: center;
  }
  .goods-info p{
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /*规定段落中的文本不进行换行：*/
    text-align: center;
    font-size: 13px;
  }
  .goods-info .price{
    color: var(--color-high-text);
    margin-left: 10px;
    margin-right: 20px;
    font-size: 10px;

  }
  .goods-info .collect{
    color: red;
    font-size: 10px;
  }

</style>